package com.roocon.thread;

public class Test {



  public static void main(String[] args) {
    Object lock = new Object();
    new Thread(new Runnable() {
      @Override public void run() {
        synchronized (lock) {
          try {
            System.out.println("B go to working!");
            lock.wait();
          } catch (InterruptedException e) {
            e.printStackTrace();
            System.out.println("Interrupt wait exception!! ");
          }
          System.out.println("B finish ... ");
        }
      }
    }).start();

    new Thread(new Runnable() {
      @Override public void run() {
        synchronized (lock) {
          try {
            System.out.println("C go to working!");
            //lock.wait();
            lock.wait(2000);
          } catch (InterruptedException e) {
            e.printStackTrace();
            System.out.println("C Interrupt wait exception!! ");
          }
          System.out.println("C finish ... ");
        }
      }
    }).start();


    new Thread(new Runnable() {
      @Override public void run() {
        synchronized (lock) {
          System.out.println("go to working...");
          try {
            Thread.sleep(5000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
          System.out.println("A finish...");
          lock.notify();
        }
      }
    }).start();



  }
}
